//-------------------------------------------------------------------------------------------------
// <copyright file="SA1101.cs" company="OfficeClip LLC">
// Copyright (c) OfficeClip LLC.  All rights reserved.
// </copyright>
//-------------------------------------------------------------------------------------------------

namespace OfficeClip.OpenSource.StyleFix.Drivers
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Text.RegularExpressions;

    public class SA1101
    {
        public static string Run(string input, SAObject saob)
        {
            // Find the variable
            string[] arrayWord = saob.Description.Split(" ".ToCharArray());

            // The fourth letter happens to be the filename
            string retStr = Regex.Replace(
                 input,
				 string.Format(@"(\s|\()({0})(\W)", arrayWord[3]),
                 "$1this.$2$3",
                 RegexOptions.None);

            // sometimes the same error is shown twice and the this. is repeated... so we need to take one out
            return retStr.Replace("this.this.", "this.");
        }
    }
}
